package cn.edu.cjw.APMFP.ui.table;

import cn.edu.cjw.APMFP.RoleRight.pojo.RoleRight;
import cn.edu.cjw.APMFP.WorkStep.pojo.WorkStep;

import javax.swing.table.AbstractTableModel;
import java.util.List;

/**
 * @package 工序
 * @className WorkStepTableModel
 * @note TODO
 * @author wind
 * @date 2022/3/12 13:19
 */
public class WorkStepTableModel extends AbstractTableModel {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    private List<WorkStep> list;
    private String[] columns = { "编号", "名称",  "描述"};

    public WorkStepTableModel(List<WorkStep> list) {
        super();
        this.list = list;
    }

    @Override
    public int getRowCount() {
        return list.size();
    }

    @Override
    public int getColumnCount() {
        return columns.length;
    }

    @Override
    public String getColumnName(int column) {
        return columns[column];
    }

    private Object getColumn(WorkStep entity, int n) {
        switch (n) {
            case 0: return entity.getWId();
            case 1: return entity.getWName();
            case 2: return entity.getWDescribe();
            default: return null;
        }
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return getColumn(list.get(rowIndex), columnIndex);
    }
}
